//
//  YXBuyController.m
//  彩票
//
//  Created by mac on 15-3-30.
//  Copyright (c) 2015年 mac. All rights reserved.
//

#import "YXBuyController.h"
#import "YXButton.h"

@implementation YXBuyController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // 加载右侧按键
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem initWith:@"NavInfoFlat" andSelecte:@"" andTitle:@"发起合买" andTarget:nil andActivity:nil];
     // 创建btn为titleview
    YXButton *btnview = [YXButton buttonWithType:UIButtonTypeCustom];
    [btnview setTitle:@"全部彩种" forState:UIControlStateNormal];
    [btnview setImage:[UIImage imageNamed:@"YellowDownArrow"] forState:UIControlStateNormal];
    // btnview.frame = CGRectMake(10, 10, 100,15);
    [btnview sizeToFit];
    self.navigationItem.titleView = btnview;
    [btnview addTarget:self action:@selector(btnviewClick:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)btnviewClick:(YXButton *)btn
{
    btn.selected = !btn.selected;
    if (btn.selected) {
        [UIView animateWithDuration:0.7 animations:^{
            btn.imageView.transform = CGAffineTransformMakeRotation(M_PI + 0.0001);
        }];
    }else if (!btn.selected){
        [UIView animateWithDuration:0.7 animations:^{
            btn.imageView.transform = CGAffineTransformIdentity;
        }];
    }
    
    
    
}

@end
